/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2018-2019 Erik Moqvist
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use, copy,
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/**
 * This file was generated by cantools version 39.4.5 Mon Apr 15 14:49:13 2024.
 */

#ifndef ZT_H
#define ZT_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>

#ifndef EINVAL
#    define EINVAL 22
#endif

/* Frame ids. */
#define ZT_INDICATOR_FRAME_ID (0x18f00117u)
#define ZT_CCVS_FRAME_ID (0x18fef117u)
#define ZT_VEHICLE_STATUS_FRAME_ID (0x18ff4aefu)

/* Frame lengths in bytes. */
#define ZT_INDICATOR_LENGTH (8u)
#define ZT_CCVS_LENGTH (8u)
#define ZT_VEHICLE_STATUS_LENGTH (8u)

/* Extended or standard frame types. */
#define ZT_INDICATOR_IS_EXTENDED (1)
#define ZT_CCVS_IS_EXTENDED (1)
#define ZT_VEHICLE_STATUS_IS_EXTENDED (1)

/* Frame cycle times in milliseconds. */


/* Signal choices. */


/* Frame Names. */
#define ZT_INDICATOR_NAME "Indicator"
#define ZT_CCVS_NAME "CCVS"
#define ZT_VEHICLE_STATUS_NAME "Vehicle_status"

/* Signal Names. */
#define ZT_INDICATOR_DASH_INDICATOR_NAME "Dash_indicator"
#define ZT_CCVS_DASH_VEHICLE_SPEED_NAME "Dash_VehicleSpeed"
#define ZT_VEHICLE_STATUS_CURRENT_GEAR_NAME "Current_Gear"

/**
 * Signals in message Indicator.
 *
 * All signal values are as on the CAN bus.
 */
struct zt_indicator_t {
    /**
     * Range: 0..3 (0..3 -)
     * Scale: 1
     * Offset: 0
     */
    uint8_t dash_indicator;
};

/**
 * Signals in message CCVS.
 *
 * All signal values are as on the CAN bus.
 */
struct zt_ccvs_t {
    /**
     * Range: 0..65535 (0..255.99609 -)
     * Scale: 0.00390625
     * Offset: 0
     */
    uint16_t dash_vehicle_speed;
};

/**
 * Signals in message Vehicle_status.
 *
 * All signal values are as on the CAN bus.
 */
struct zt_vehicle_status_t {
    /**
     * Range: 0..15 (0..15 -)
     * Scale: 1
     * Offset: 0
     */
    uint8_t current_gear;
};

/**
 * Pack message Indicator.
 *
 * @param[out] dst_p Buffer to pack the message into.
 * @param[in] src_p Data to pack.
 * @param[in] size Size of dst_p.
 *
 * @return Size of packed data, or negative error code.
 */
int zt_indicator_pack(
    uint8_t *dst_p,
    const struct zt_indicator_t *src_p,
    size_t size);

/**
 * Unpack message Indicator.
 *
 * @param[out] dst_p Object to unpack the message into.
 * @param[in] src_p Message to unpack.
 * @param[in] size Size of src_p.
 *
 * @return zero(0) or negative error code.
 */
int zt_indicator_unpack(
    struct zt_indicator_t *dst_p,
    const uint8_t *src_p,
    size_t size);

/**
 * Init message fields to default values from Indicator.
 *
 * @param[in] msg_p Message to init.
 *
 * @return zero(0) on success or (-1) in case of nullptr argument.
 */
int zt_indicator_init(struct zt_indicator_t *msg_p);

/**
 * Encode given signal by applying scaling and offset.
 *
 * @param[in] value Signal to encode.
 *
 * @return Encoded signal.
 */
uint8_t zt_indicator_dash_indicator_encode(double value);

/**
 * Decode given signal by applying scaling and offset.
 *
 * @param[in] value Signal to decode.
 *
 * @return Decoded signal.
 */
double zt_indicator_dash_indicator_decode(uint8_t value);

/**
 * Check that given signal is in allowed range.
 *
 * @param[in] value Signal to check.
 *
 * @return true if in range, false otherwise.
 */
bool zt_indicator_dash_indicator_is_in_range(uint8_t value);

/**
 * Pack message CCVS.
 *
 * @param[out] dst_p Buffer to pack the message into.
 * @param[in] src_p Data to pack.
 * @param[in] size Size of dst_p.
 *
 * @return Size of packed data, or negative error code.
 */
int zt_ccvs_pack(
    uint8_t *dst_p,
    const struct zt_ccvs_t *src_p,
    size_t size);

/**
 * Unpack message CCVS.
 *
 * @param[out] dst_p Object to unpack the message into.
 * @param[in] src_p Message to unpack.
 * @param[in] size Size of src_p.
 *
 * @return zero(0) or negative error code.
 */
int zt_ccvs_unpack(
    struct zt_ccvs_t *dst_p,
    const uint8_t *src_p,
    size_t size);

/**
 * Init message fields to default values from CCVS.
 *
 * @param[in] msg_p Message to init.
 *
 * @return zero(0) on success or (-1) in case of nullptr argument.
 */
int zt_ccvs_init(struct zt_ccvs_t *msg_p);

/**
 * Encode given signal by applying scaling and offset.
 *
 * @param[in] value Signal to encode.
 *
 * @return Encoded signal.
 */
uint16_t zt_ccvs_dash_vehicle_speed_encode(double value);

/**
 * Decode given signal by applying scaling and offset.
 *
 * @param[in] value Signal to decode.
 *
 * @return Decoded signal.
 */
double zt_ccvs_dash_vehicle_speed_decode(uint16_t value);

/**
 * Check that given signal is in allowed range.
 *
 * @param[in] value Signal to check.
 *
 * @return true if in range, false otherwise.
 */
bool zt_ccvs_dash_vehicle_speed_is_in_range(uint16_t value);

/**
 * Pack message Vehicle_status.
 *
 * @param[out] dst_p Buffer to pack the message into.
 * @param[in] src_p Data to pack.
 * @param[in] size Size of dst_p.
 *
 * @return Size of packed data, or negative error code.
 */
int zt_vehicle_status_pack(
    uint8_t *dst_p,
    const struct zt_vehicle_status_t *src_p,
    size_t size);

/**
 * Unpack message Vehicle_status.
 *
 * @param[out] dst_p Object to unpack the message into.
 * @param[in] src_p Message to unpack.
 * @param[in] size Size of src_p.
 *
 * @return zero(0) or negative error code.
 */
int zt_vehicle_status_unpack(
    struct zt_vehicle_status_t *dst_p,
    const uint8_t *src_p,
    size_t size);

/**
 * Init message fields to default values from Vehicle_status.
 *
 * @param[in] msg_p Message to init.
 *
 * @return zero(0) on success or (-1) in case of nullptr argument.
 */
int zt_vehicle_status_init(struct zt_vehicle_status_t *msg_p);

/**
 * Encode given signal by applying scaling and offset.
 *
 * @param[in] value Signal to encode.
 *
 * @return Encoded signal.
 */
uint8_t zt_vehicle_status_current_gear_encode(double value);

/**
 * Decode given signal by applying scaling and offset.
 *
 * @param[in] value Signal to decode.
 *
 * @return Decoded signal.
 */
double zt_vehicle_status_current_gear_decode(uint8_t value);

/**
 * Check that given signal is in allowed range.
 *
 * @param[in] value Signal to check.
 *
 * @return true if in range, false otherwise.
 */
bool zt_vehicle_status_current_gear_is_in_range(uint8_t value);


#ifdef __cplusplus
}
#endif

#endif
